<template>
    <el-button @click="openRemoveAction" type="danger">
        <el-icon>
            <Delete/>
        </el-icon>
        批量删除
    </el-button>
    <el-dialog :model-value="openRemove"
               :lock-scroll="false"
               append-to-body
               @close="closeRemove"
               title="删除" width="50%">
      <span>
      确认删除
    </span>
        <template #footer>
            <el-button type="danger" @click="remove${humpName}Action">
                确认
            </el-button>
        </template>
    </el-dialog>
</template>
<script setup>
    import {remove${humpName} } from "@/api/${serviceName}/${humpName}Api.js";
    import {ElMessage} from "element-plus";
    import {ref} from "vue";
    import {useSearchStore} from "@/store/SearchStore.js";
    import {Delete} from "@element-plus/icons-vue";

    const openRemove = ref(false)
    const searchStore = useSearchStore()

    const closeRemove = () => {
        openRemove.value = false
    }

    const openRemoveAction = () => {
        if (searchStore.selectIds.length === 0) {
            ElMessage.warning("请选择数据！");
            return
        }
        openRemove.value = true
    }

    const remove${humpName}Action = () => {
        remove${humpName}(searchStore.selectIds).then(res => {
            ElMessage.success(res.message)
        }).finally(() => {
            openRemove.value = false
            searchStore.selectIds = ''
            searchStore.noticePageRefresh()
        })
    }

</script>
